﻿Imports System.ComponentModel

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class ucLectureStudentDetails
    Inherits UcBaseEditControl
    Implements IUcEditControl

#Region "Designer"
    'UserControl overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()
        
        ' Add any initialization after the InitializeComponent() call.
        
    End Sub
    Friend WithEvents PeriodIdLbl As System.Windows.Forms.Label
    Friend WithEvents Period As org.codegen.win.controls.CGTextBox
    Public WithEvents UcLectureList As IIC.ucLectureList
    Friend WithEvents StudentNameLbl As System.Windows.Forms.Label


    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Me.MemberNolbl = New System.Windows.Forms.Label()
        Me.MemberNo = New org.codegen.win.controls.CGTextBox(Me.components)
        Me.PeriodIdLbl = New System.Windows.Forms.Label()
        Me.Period = New org.codegen.win.controls.CGTextBox(Me.components)
        Me.StudentNameLbl = New System.Windows.Forms.Label()
        Me.UcLectureList = New IIC.ucLectureList()
        CType(Me.ErrProvider, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'MemberNolbl
        '
        Me.MemberNolbl.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.MemberNolbl.Location = New System.Drawing.Point(5, 37)
        Me.MemberNolbl.Name = "MemberNolbl"
        Me.MemberNolbl.Size = New System.Drawing.Size(169, 20)
        Me.MemberNolbl.TabIndex = 2
        Me.MemberNolbl.Text = "Member No or ID Number"
        Me.MemberNolbl.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'MemberNo
        '
        Me.MemberNo.AssociatedLabel = Me.MemberNolbl
        Me.MemberNo.BackColor = System.Drawing.Color.LightYellow
        Me.MemberNo.ErrProvider = Nothing
        Me.MemberNo.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.MemberNo.FormatPattern = Nothing
        Me.MemberNo.isMandatory = True
        Me.MemberNo.Location = New System.Drawing.Point(180, 38)
        Me.MemberNo.MaxLength = 255
        Me.MemberNo.MaxValue = Nothing
        Me.MemberNo.MinValue = Nothing
        Me.MemberNo.Name = "MemberNo"

        Me.MemberNo.Size = New System.Drawing.Size(104, 21)
        Me.MemberNo.TabIndex = 3
        '
        'PeriodIdLbl
        '
        Me.PeriodIdLbl.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.PeriodIdLbl.Location = New System.Drawing.Point(5, 10)
        Me.PeriodIdLbl.Name = "PeriodIdLbl"
        Me.PeriodIdLbl.Size = New System.Drawing.Size(169, 20)
        Me.PeriodIdLbl.TabIndex = 4
        Me.PeriodIdLbl.Text = "Period"
        Me.PeriodIdLbl.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Period
        '
        Me.Period.AssociatedLabel = Me.PeriodIdLbl
        Me.Period.BackColor = System.Drawing.Color.LightYellow
        Me.Period.ErrProvider = Nothing
        Me.Period.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Period.FormatPattern = Nothing
        Me.Period.isMandatory = True
        Me.Period.Location = New System.Drawing.Point(180, 11)
        Me.Period.MaxLength = 255
        Me.Period.MaxValue = Nothing
        Me.Period.MinValue = Nothing
        Me.Period.Name = "Period"

        Me.Period.Size = New System.Drawing.Size(535, 21)
        Me.Period.TabIndex = 5
        '
        'StudentNameLbl
        '
        Me.StudentNameLbl.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(161, Byte))
        Me.StudentNameLbl.ForeColor = System.Drawing.Color.DarkRed
        Me.StudentNameLbl.Location = New System.Drawing.Point(301, 38)
        Me.StudentNameLbl.Name = "StudentNameLbl"
        Me.StudentNameLbl.Size = New System.Drawing.Size(413, 21)
        Me.StudentNameLbl.TabIndex = 7
        Me.StudentNameLbl.Text = "StudentNameLbl"
        Me.StudentNameLbl.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'UcLectureList
        '
        Me.UcLectureList.Location = New System.Drawing.Point(18, 90)
        Me.UcLectureList.Name = "UcLectureList"
        Me.UcLectureList.Size = New System.Drawing.Size(700, 218)
        Me.UcLectureList.TabIndex = 6
        '
        'ucLectureStudentDetails
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.AutoValidate = System.Windows.Forms.AutoValidate.EnableAllowFocusChange
        Me.Controls.Add(Me.StudentNameLbl)
        Me.Controls.Add(Me.UcLectureList)
        Me.Controls.Add(Me.PeriodIdLbl)
        Me.Controls.Add(Me.Period)
        Me.Controls.Add(Me.MemberNolbl)
        Me.Controls.Add(Me.MemberNo)
        Me.Name = "ucLectureStudentDetails"
        Me.Size = New System.Drawing.Size(735, 321)
        CType(Me.ErrProvider, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub



    Friend WithEvents MemberNolbl As System.Windows.Forms.Label
    Friend WithEvents MemberNo As CGTextBox


#End Region

#Region "Methods"

    Private _studentId As Integer = 0

    Public Property studentId As Integer
        Get
            Return _studentId
        End Get

        Set(ByVal value As Integer)
            _studentId = value
            If _studentId = 0 Then
                Me.MemberNo.Text = ""
                Me.StudentNameLbl.Text = String.Empty
            End If

        End Set

    End Property

    Private lecturePeriod As Period

    ''' <summary>
    ''' Fills the controls on the screen from data in the object
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub _loadData() Handles Me.evLoadObjectData
        Me.studentId = 0
        Me.lecturePeriod = PeriodDataUtils.findByKey(My.Settings.CurrentPeriodId)

        If lecturePeriod IsNot Nothing Then
            Me.Period.Text = lecturePeriod.PeriodDescription
            Me.UcLectureList.grdLecture.gpWhereclause = "periodId=" & lecturePeriod.PeriodId
            Me.UcLectureList.grdLecture.loadGrid()

        Else
            Throw New ApplicationException("The current period must be selected")
        End If

        Me.resetLastLoadedValues()
        Me.ErrProvider.Clear()

    End Sub


#End Region

    Private Sub MemberNo_KeyDown(ByVal sender As Object, _
                                 ByVal e As System.Windows.Forms.KeyEventArgs) Handles MemberNo.KeyDown

        If e.KeyCode = Keys.Enter Then

            If Me.studentId > 0 Then
                'means we searched and found an person
                Dim f As frmBaseEdit = CType(Me.ParentForm, frmBaseEdit)
                Call f.SaveData()
            Else

                Dim student As Student = StudentDataUtils.findOne( _
                            "(idNumber={0} or MemberNumber={1})", _
                            Me.MemberNo.Text, Me.MemberNo.Text)

                If student IsNot Nothing Then
                    Me.studentId = student.StudentId
                    Me.StudentNameLbl.Text = student.StudentFullName
                Else
                    Me.studentId = 0
                    Me.StudentNameLbl.Text = String.Empty
                End If
            End If
        End If
    End Sub

   
End Class


